//**************获取角色信息*****************************************************************
function getInfoByRole(json){
	if(json.statusCode==DWZ.statusCode.error){
		navTabAjaxDone(json)
	}else{
		var content="";
		$(json).each(function(n,item){
			var numPerPage=item.numPerPage;
			var currentPage=item.currentPage;
			var totalCount=item.totalCount;
			var pageCount=item.pageCount;
			var list=item.list;
			//alert(numPerPage+","+currentPage+","+pageCount)
			if(list.length==0){
				content+="<tr><td colspan='6' align='center' >未查询到数据</td></tr>"
			}else{
				for(var i=0;i<list.length;i++){
					var roleExplain=""
					if(list[i].roleExplain!=null){
						roleExplain=list[i].roleExplain;
					}
					content+="<tr onmouseover='moveoverMouse(this)' onmouseout='moveoutMouse(this)' align='center'><td><input  name='roleManage' onclick='test(this)' type='checkbox' value="+list[i].roleId+" /></td><td>"+list[i].roleId+"</td><td>"+
					list[i].roleNo+"</td><td>"+list[i].roleName+"</td><td>"+roleExplain+"</td><td>"+list[i].roleOwner+"</td><td><input class='newButton'  type='button' value='人员设置' onclick='personnelSet(this)'> <input class='newButton' type='button' value='功能授权' onclick='accredit(this)'></td></tr>"
				}
			}
			$("#tbodyByRole").html(content);
			$("input[name='numPerPage']").val(numPerPage);
			$("input[name='pageNum']").val(currentPage); 
//			$("input[name='pageCount']").val(pageCount);
			$("#totalCountByRole").text("条，共"+totalCount+"条");
//			var pagination="<a href='#' onclick="+"previous($('#getInfoByRole'),getInfoByRole) id='previous' >上一页  </a><a href='#' onclick="+"next($('#getInfoByRole'),getInfoByRole) id='next'> 下一页</a><span>当前第"+currentPage+"页，共"+pageCount+"页</span>";
//			$("#paginationByRole").html(pagination);
			$("#paginationByRole").addClass("pagination").attr("targetType","navTab").attr("totalCount",totalCount).attr("numPerPage",numPerPage).attr("pageNumShown","10").attr("currentPage",currentPage).attr("rel","tbodyByRole").attr("callback","getInfoByRole");
			$("div.pagination").each(function(){
				var $this = $(this);
				$this.pagination({
					targetType:"navTab",
					rel:"tbodyByRole",
					totalCount:totalCount,
					numPerPage:numPerPage,
					pageNumShown:10,
					currentPage:currentPage,
					callback:getInfoByRole
				});
			});
			var $p = $("#ByRoleManage");
			initUI($p);
		});
	}
	
}


//***************给角色设置人员获取柜员信息****************************************************
function getTellerInfoByPersonalSet(json){
	if(json.statusCode==DWZ.statusCode.error){
		navTabAjaxDone(json)
	}else{
		var content="";
		$(json).each(function(n,item){
			var numPerPage=item.numPerPage;
			var currentPage=item.currentPage;
			var totalCount=item.totalCount;
			var pageCount=item.pageCount;
			var list=item.list;
			//alert(numPerPage+","+","+currentPage+","+pageCount)
			if(list.length==0){
				content+="<tr><td colspan='3' align='center' >未查询到数据</td></tr>"
			}else{
				for(var i=0;i<list.length;i++){
					var value=list[i].userNo;    /*+","+list[i].roleId*/
					content+="<tr onmouseover='moveoverMouse(this)' onmouseout='moveoutMouse(this)' align='center'><td><input  name='personalSet' onchange='commitByRole(this)' type='checkbox' value="+value+" /></td><td>"+
					list[i].userNo+"</td><td>"+list[i].userName+"</td></tr>"
				}
			}
			$("#tbodyByPersonalSet").html(content);
			$("input[name='numPerPage']").val(numPerPage);
			$("input[name='pageNum']").val(currentPage); 
//			$("input[name='pageCount']").val(pageCount);
			$("#totalCountByPersonalSet").text("条，共"+totalCount+"条");
//			var pagination="<a href='#' onclick="+"previous($('#getTellerInfoByPersonalSet'),getTellerInfoByPersonalSet) id='previous' >上一页  </a><a href='#' onclick="+"next($('#getTellerInfoByPersonalSet'),getTellerInfoByPersonalSet) id='next'> 下一页</a><span>当前第"+currentPage+"页，共"+pageCount+"页</span>";
//			$("#paginationByPersonalSet").html(pagination);
			$("#paginationByPersonalSet").addClass("pagination").attr("targetType","dialog").attr("totalCount",totalCount).attr("numPerPage",numPerPage).attr("pageNumShown","10").attr("currentPage",currentPage).attr("rel","tbodyByPersonalSet").attr("callback","getTellerInfoByPersonalSet");
			$("#paginationByPersonalSet").each(function(){
				var $this = $(this);
				$this.pagination({
					targetType:"dialog",
					rel:"tbodyByPersonalSet",
					totalCount:totalCount,
					numPerPage:numPerPage,
					pageNumShown:10,
					currentPage:currentPage,
					callback:getTellerInfoByPersonalSet
				});
			});
			var $p = $("#ByPersonalSet");
			initUI($p);
			//判断是否选中状态
			var roleId=$("input[name='roleId']").val();
			for(var i=0;i<list.length;i++){
				if(list[i].roleId==roleId){
					$("input[name='personalSet']:eq("+i+")").attr("checked","checked")
				}
			}
			
		});
	}
	
}
//**角色设置人员，选中一个设置一个*************************************************************
function commitByRole(a){
	var roleId=$("input[name='roleId']").val();
	var sysId=$("input[name='sysId']").val();
	var userNo=$(a).val();
	alertMsg.confirm("是否确定", {
		okCall: function(){
	if($(a).attr("checked")){
		//alert("选中"+$(a).val());
		$.post("roleManage/commitPersonalSet",{sysId:sysId,roleId:roleId,userNo:userNo,sign:"1"},function(json){
			$(a).attr("checked",true)
		},"json");
	}else{
		//alert("取消"+$(a).val());
		$.post("roleManage/commitPersonalSet",{sysId:sysId,roleId:roleId,userNo:userNo,sign:"0"},function(json){
			$(a).removeAttr("checked")
		},"json");		
	}
	test(a)
		},
	cancelCall: function(){
		$.post("roleManage/getTellerInfoByPersonalSet",getTellerInfoByPersonalSet,"json"); 
	 }
})
}